package com.dingup.provider.service.lesson.impl;

import com.dingup.api.model.lesson.LessonSubjectInfo;
import com.dingup.provider.mapper.LessonSubjectInfoMapper;
import com.dingup.provider.service.lesson.LessonSubjectInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by wancheng on 2018/8/30.
 */
@Service
public class LessonSubjectInfoServiceImpl implements LessonSubjectInfoService{

    @Autowired
    LessonSubjectInfoMapper lessonSubjectInfoMapper;

    public void needInsert(List<LessonSubjectInfo> needInsert, String operaUserId, Integer lessonId){
        //operaUserId classId用来记录日志
        needInsert.stream().forEach(
                lessonSubjectInfo -> {
                    lessonSubjectInfo.setLessonId(lessonId);
                    lessonSubjectInfoMapper.insertSelective(lessonSubjectInfo);
                }
        );
    }

    public void needUpdate(List<LessonSubjectInfo> needInsert, String operaUserId,Integer lessonId){
        //operaUserId classId用来记录日志
        needInsert.stream().forEach(
                lessonSubjectInfo -> {
                    lessonSubjectInfo.setLessonId(lessonId);
                    lessonSubjectInfoMapper.updateByPrimaryKeySelective(lessonSubjectInfo);
                }
        );
    }

    public void needDelete(List<LessonSubjectInfo> needDelete, String operaUserId,Integer lessonId){
        //operaUserId classId用来记录日志
        needDelete.stream().forEach(
                lessonSubjectInfo -> {
                    lessonSubjectInfoMapper.deleteByPrimaryKey(lessonSubjectInfo.getId());
                }
        );
    }
}
